Infinite Loop (IL)

Description:

IL detects situations where a while, do, or for loop has a constant loop condition and no exit from the loop body. Such a loop executes infinitely.

Incorrect:

int Sum(int[][] arr) {
    int s = 0;
    for (int i = 0; i < arr.Length; i++) {
        for (int j = 0; j < arr[i].Length; i++) {
            s += arr[i][j];
        }
    }
    return s;
}

Correct:

int Sum(int[][] arr) {
    int s = 0;
    for (int i = 0; i < arr.Length; i++) {
        for (int j = 0; j < arr[i].Length; j++) {
            s += arr[i][j];
        }
    }
    return s;
}